﻿using Pantry.DataAccess;
using System.Data;
using Pantry.Entity;

namespace Pantry.Business
{
    public class SupportingMaterialBus
    {
        private SupportingMaterialDao _supDao;

        public SupportingMaterialBus()
        {
            _supDao = new SupportingMaterialDao();
        }

        /// <summary>
        /// Marks the activated.
        /// </summary>
        /// <param name="isActive">if set to <c>true</c> [is active].</param>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public bool MarkActivated(bool isActive, int id)
        {
            int result = _supDao.MarkActivated(isActive, id);
            return (result > 0);
        }

        /// <summary>
        /// Selects all supporting material.
        /// </summary>
        /// <returns></returns>
        public DataTable SelectAllSupportingMaterialByOrgId(int id)
        {
            return _supDao.SelectAllSupportingMaterialByOrgId(id);
        }

        /// <summary>
        /// Selects the supporting material by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public SupportingMaterial SelectSupportingMaterialById(int id)
        {
            return _supDao.SelectSupportingMaterialById(id);
        }

        /// <summary>
        /// Inserts the supporting material.
        /// </summary>
        /// <param name="sm">The sm.</param>
        /// <returns></returns>
        public int InsertSupportingMaterial(SupportingMaterial sm)
        {
            return _supDao.InsertSupportingMaterial(sm);
        }

        /// <summary>
        /// Updates the supporting material.
        /// </summary>
        /// <param name="sm">The sm.</param>
        /// <returns></returns>
        public int UpdateSupportingMaterial(SupportingMaterial sm)
        {
            return _supDao.UpdateSupportingMaterial(sm);
        }

        public string SelectedItemOrganisationName(int materialId)
        {
            return _supDao.SelectedItemOrganisationName(materialId);
        }

        /// <summary>
        /// Selects the name of the org.
        /// </summary>
        /// <returns></returns>
        public DataTable SelectOrgName()
        {
            return _supDao.SelectOrgName();
        }
    }
}
